﻿using System;
using System.Web.UI;

using Sunyi.Project.WebPoint.BusinessLogic;
using Sunyi.Project.WebPoint.Common;
using Sunyi.Project.WebPoint.DataContract;
using Sunyi.Project.WebPoint.WebControl;

namespace ActivitySystem.Web.Admin
{
    public partial class LogDetail : WebPointPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    if (!string.IsNullOrEmpty(Request.Params[WebPointGlobalConstant.LogId]))
                    {
                        Guid logId = new Guid(Request.Params[WebPointGlobalConstant.LogId]);
                        BindLog(logId);
                    }
                }
                catch (Exception ex)
                {
                    ExceptionHandler.Handle(this, ex);
                }
            }
        }

        #region Private Method

        private void BindLog(Guid logId)
        {
            Log log = Logger.Select(logId);

            if (log != null)
            {
                tbxId.Text = log.Id.ToString();
                tbxLevel.Text = log.Level;
                tbxSource.Text = log.Source;
                tbxCategory.Text = log.Category;
                tbxEventId.Text = log.EventId;
                tbxInsertTimestamp.Text = log.InsertTimestamp.ToString();
                tbxData.Text = log.Data;
            }
        }

        #endregion
    }
}